<template>
  <div class="template-index-Lu">
    <commpVxeTable
          :isCanWrap="true"
          :conditionBtnRow="true"
          :key="reCommpVxeTable"
          :config="dataTableConfig"
          :columns="columnsVxe"
          :formItem="formItem"
          @checkboxChange="checkboxChange"
          ref="administrativeOffice"
          @searchEvent="searchEvent"
          @resetEvent="resetEvent"
          >
        <template v-slot:operation_fcykssj="{row}" data-desc="审评时间">
          <span>
            {{ row.fcykssj }} 至 {{ row.fcyjssj }}
          </span>
        </template>
        <template v-slot:fhjmc_name="{row}">
            {{ row.fhjmc == '检查员互评'?'审评员互评':row.fhjmc }}
        </template>
        <template v-slot:operation_ffsrmc="{row}" data-desc="发送人">
              <span style="padding-right: 21;" v-if="row.ffsrmc&&row.ffsrmc.length == 2">
                  <span v-for="(trem,tI) in row.ffsrmc.split('')" :key="tI" >
                      {{trem}}
                      <span v-if="tI+1 !== row.ffsrmc.split('').length">&nbsp;&nbsp;</span>
                  </span>
              </span>
              <span style="padding-right: 21;" v-else>{{ row.ffsrmc }}</span>
          </template>
          <template v-slot:operation_btn="{row}" data-desc="自定操作栏">
              <a-form layout="inline">
                  <a-form-item>
                      <a-button class="blue-btn" @click="reviseClick(row)" icon="edit">办理</a-button>
                  </a-form-item>
              </a-form>
          </template>
      </commpVxeTable>
      <huHandleModal ref="huHandleModalRef" @success="success"></huHandleModal>
      <handleModal ref="handleModalRef" @success="success"></handleModal>
  </div>
</template>
<script>
import  commpVxeTable   from '@/components/commp-vxe-table/commp-vxe-table.vue'
import  assessCheckApi  from './service/api'
import handleModal from './handleModal.vue'
import huHandleModal from './huHandleModal.vue'
export default {
  components: {
      commpVxeTable,handleModal,huHandleModal
  },
  data() {
    return {
          reCommpVxeTable: '',
          dataTableConfig: {
              api: assessCheckApi.flowJobPage,
              rowId: 'id',
              paramet: {}
          },
          columnsVxe: [
              {
                  type: 'checkbox',
                  width: 60,
                  fixed: 'left'
              },{
                  title: '企业名称',
                  field: 'fqymc',
              },{
                  title: '事项名称',
                  field: 'fsxmc',
              },{
                  title: '环节名称',
                  field: 'fhjmc',
                  slots: {
                      default:'fhjmc_name',
                  },
                  width: 120,
              },{
                  title: '发送人',
                  field: 'ffsrmc',
                  width: 100,
                  interval:true,
                  slots: {
                      default:'operation_ffsrmc',
                  }
              },{
                  title: '发送时间',
                  field: 'ffssj',
                  width: 200,
              },{
                  title: '审评时间',
                  field: 'fcykssj',
                  width: 250,
                  slots: {
                      default: 'operation_fcykssj',
                  },
              },{
                  title: '操作',
                  field: 'id',
                  width: 100,
                  titleInterval:true,
                  slots: {
                  // 使用插槽模板渲染
                      header:'data2_header',
                      default: 'operation_btn',
                  },
              }
          ],
          formItem: [
              {
                  label: '关键字',
                  model: 'gjz',
              },
          ],
          idList: [],
          formData: {},
      }
  },
  methods: {
      // 勾选
      checkboxChange(val){
          //console.log('已选择',val)
          this.idList = []
          if(val.length){
              val.forEach(item => {
                  this.idList.push(item.id)
              });
          }
      },
      // 搜索
      searchEvent(){
          this.dataTableConfig.paramet = {
              ...this.dataTableConfig.paramet,
          }
      },
      // 重置
      resetEvent(){
          //console.log('重置')
          this.reCommpVxeTable = Date.now()
          this.dataTableConfig.paramet = {
              ...this.dataTableConfig.paramet,
          }
      },
      reviseClick(row){
        //console.log(row)
        this.$nextTick(() => {
          if(row.fhjmc == '检查员互评'){
            this.$refs.huHandleModalRef.getData(row,false)
            this.$refs.huHandleModalRef.huHandleModalVisible = true
          }
          if(row.fhjmc == '经办人审核'){
            this.$refs.handleModalRef.getData(row,true,false)
            this.$refs.handleModalRef.handleModalVisible = true
          }
          if(row.fhjmc == '科室复核'){
            this.$refs.handleModalRef.getData(row,true,true)
            this.$refs.handleModalRef.handleModalVisible = true
            this.$refs.handleModalRef.isBlyj = true
          }
        })
      },
    // 弹窗关闭
    success(){
      // 刷新表格 清空id数组
      this.$refs.administrativeOffice.resetEvent()
      this.idList = []
    },
  },
}
</script>
